package com.yuyou.fn.common.service.impl;

import com.github.wens.framework.service.impl.SuperServiceImpl;
import com.yuyou.fn.common.entity.BusFailLog;
import com.yuyou.fn.common.mapper.BusFailLogMapper;
import com.yuyou.fn.common.service.IBusFailLogService;
import com.yuyou.fn.common.service.ISmsService;
import com.yuyou.fn.common.util.Threads;
import com.yuyou.fn.common.util.TimeUtils;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Arrays;

/**
 *
 * BusFailLog 表数据服务层接口实现类
 *
 */
@Service
public class BusFailLogServiceImpl extends SuperServiceImpl<BusFailLogMapper, BusFailLog,Long> implements IBusFailLogService {

    @Resource
    private ISmsService smsService ;

    @Override
    public void log(final String busType, String content) {
        BusFailLog log = new BusFailLog();
        log.setBusType(busType);
        log.setLog(content);
        log.setCreateTime(TimeUtils.now());
        log.setUpdateTime(TimeUtils.now());
        log.setIsDone(0);
        insertSelective(log);

        Threads.dispatch(new Runnable() {
            @Override
            public void run() {
                try {
                    smsService.send(Arrays.asList("18312421977") ,"十万火急:" + busType );
                } catch (Exception e) {
                    //
                }
            }
        });
    }
}